
import java.util.Random;

public class C {

	public static void main(String[] args) {
		Random random = new Random();
		int[] a=new int[10];
		for (int i = 0; i < 10; i++) {
			a[i]=random.nextInt(10);
		}
		System.out.println(a);
		int b=a[0];
		int c=a[0];
		int d=0;
		int e=0;
		for (int i = 0; i < 10; i++) {
			if (b<a[i]) {
				b=a[i];
				d=i;
			}
			if (c>a[i]) {
				c=a[i];
				e=i;
			}
		}
		shu(a,b,c,d,e);
		System.out.println(a);
	}
	public static void shu(int a[],int b,int c,int d,int e) {
		a[d]=a[0];
		a[e]=a[9];
		a[0]=b;
		a[9]=c;
	}

}